package com.nsl.my_youlai.bbu2.service.impl;

import com.nsl.my_youlai.bbu2.model.bo.ApparatusRoomBo;
import com.nsl.my_youlai.bbu2.model.bo.bbu.Bbu2;
import com.nsl.my_youlai.mystar.easy_excel.model.ExcelReadResult;
import com.nsl.my_youlai.mystar.enums.NslEnumTransformException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

@Slf4j
@Service
@RequiredArgsConstructor
public class BbuAndApparatusRoomServiceImpl {

    final BbuStatusExcelStringVoServiceImpl bbuVoService;

    final BbuServiceImpl bbuBoService;

    final  ApparatusRoomServiceImpl roomService;

    public void m1(String excelFilePath,String roomSheetName,String bbuSheetName) throws NslEnumTransformException {
        ExcelReadResult readResult=bbuVoService.parseBbuStatusExcelSheet(excelFilePath,bbuSheetName);
        Map<Integer,Bbu2> bbuMap=bbuBoService.buildBbuMap(readResult.getRecordList());

        ExcelReadResult roomReadResult =roomService.readApparatusRoomVoStringFromExcel(excelFilePath,roomSheetName);
        Map<String, ApparatusRoomBo> roomBoMap=roomService.voList2BoMap(roomReadResult.getRecordList());

        for (Map.Entry<Integer, Bbu2> bbuEntry : bbuMap.entrySet()) {
            Bbu2 bbu=bbuEntry.getValue();
            String roomId=bbu.getApparatusRoomId();
            ApparatusRoomBo roomBo=roomBoMap.get(roomId);
            roomBo.getBbuList().add(bbu);
            bbu.setApparatusRoomBo(roomBo);
        }

    }

}
